package sdk.wufun.com.wfsdk_ysdk4switchpay;

import android.app.Activity;
import android.util.Log;

import com.tencent.ysdk.api.YSDKApi;
import com.wufun.sdk.WFSDK;
import com.wufun.sdk.WFUserAdapter;
import com.wufun.sdk.utils.Arrays;

public class YSDKUser extends WFUserAdapter {

	private String[] supportedMethods = {"login","loginCustom","switchLogin","logout","exit"};
	
	public YSDKUser(Activity context){
		//U8SpecialInterface.getInstance().setSpecialInterface(this);
		try{
			YSDK.initSDK(WFSDK.getInstance().getSDKParams());
		}catch(Exception e){
			e.printStackTrace();
		}

	}

	@Override
	public void login() {
		if(YSDK.useLogin){
			YSDK.login();
		}

	}

	@Override
	public void loginCustom(String customData) {
		if(YSDK.useLogin){
			if("QQ".equalsIgnoreCase(customData)){
				YSDK.login(YSDK.LOGIN_TYPE_QQ);
			}else{
				YSDK.login(YSDK.LOGIN_TYPE_WX);
			}
		}

	}


	@Override
	public void switchLogin() {
		if(YSDK.useLogin)
			YSDK.switchLogin();
	}

	@Override
	public void exit() {
//		YSDKApi.logout();
		System.exit(0);
	}

	@Override
	public void logout() {
		Log.d("WFSDK","method logout() called.");
		try{
			if(YSDK.useLogin){
				YSDK.logout();
			}

		}catch(Exception e){
			e.printStackTrace();
		}
	}

	@Override
	public boolean isSupportMethod(String methodName) {

		return Arrays.contain(supportedMethods, methodName);
	}

//	@Override
//	public boolean isFromGameCenter(Activity context) {
//
//		return false;
//	}
//
//	@Override
//	public void showGameCenter(Activity context) {
//		
//	}
//
//	//type取值： bbs或者vplayer
//	@Override
//	public void performFeature(Activity context, String type) {
//		Log.d("U8SDK", "performFeature:"+type);
//		YSDK.performFeature(type);
//	}
	
}
